<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
            <el-form-item label="时间">
                <el-date-picker
                    v-model="dateRange"
                    style="width: 215px"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                ></el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>

        <el-table v-loading="loading" :data="tableList">
            <el-table-column label="时间" prop="productionDate"/>
            <el-table-column label="新增任务" prop="productionAddnum"/>
            <el-table-column label="完成任务" prop="productionFinishnum"/>
            <el-table-column label="未完成任务" prop="productionIncompletenum"/>
        </el-table>
        <!--分页-->
        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                    @pagination="getList"/>
    </div>
</template>

<script>
import {responseEnum} from "../../../const/const";
import {getProduceRecordList} from "./api";

export default {
 name: "/produceRecord",
    data() {
        return {
            // 日期范围
            dateRange: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10
            },
            // 遮罩层
            loading: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 表格数据
            tableList: [],
        };
    },
    created() {
        this.getList();
    },
    methods: {

        /** 查询列表 */
        getList() {
            this.loading = true;
            getProduceRecordList(this.addDateRange(this.queryParams, this.dateRange)).then(res => {
                if (res.code === responseEnum.success) {
                    this.tableList = res.rows || [];
                    this.total = res.total || 0;
                }
            }).finally(() => this.loading = false);
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.queryParams = this.$options.data().queryParams;
            this.handleQuery();
        }
    }
};

</script>

<style lang="scss" scoped>

</style>
